package com.kystar.muxplayer.protocol.code.get;

import com.kystar.muxplayer.model.EDID;
import com.kystar.muxplayer.model.FreqType;
import com.kystar.muxplayer.model.SourceType;
import com.kystar.muxplayer.protocol.CodeCmd;

public class CG8E_SourceInfo extends CodeCmd {
//    1	输入亮度
//    2	输入对比度
//    3	EDID配置
//    4	智能热备份
//    5	信号有效模式
    private CG8E_SourceInfo( int sourceId,int type) {
        super(sourceId,type);
    }

    @Override
    public byte getCode() {
        return (byte) 0x8E;
    }



    public int getBright() {
        return mResult[2]&0xFF;
    }

    public int getContrast() {//对比度
        return mResult[2]&0xFF;
    }

    public EDID getEDID() {
        EDID edid = new EDID();
        edid.setWidth(mResult[3]<<8&0xFF00 | mResult[4]&0xFF);
        edid.setHeight(mResult[5]<<8&0xFF00 | mResult[6]&0xFF);
        edid.setFreqType(FreqType.values()[mResult[7]&0xFF]);
        return edid;
    }

    public SourceType getBackup() {
        return SourceType.values()[mResult[2]&0xFF];
    }



    public static CG8E_SourceInfo createSourceBrightInfo(int sourceId) {
        return new CG8E_SourceInfo(sourceId,1);
    }
    public static CG8E_SourceInfo createSourceContrastInfo(int sourceId) {
        return new CG8E_SourceInfo(sourceId,2);
    }
    public static CG8E_SourceInfo createSourceEdidInfo(int sourceId) {
        return new CG8E_SourceInfo(sourceId,3);
    }
    public static CG8E_SourceInfo createSourceBackupInfo(int sourceId) {
        return new CG8E_SourceInfo(sourceId,4);
    }
    public static CG8E_SourceInfo createSourceSignalInfo(int sourceId) {
        return new CG8E_SourceInfo(sourceId,5);
    }
}
